<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./js/vue.js"></script>
    <style>
        /* .right{
            float:left;
            width: 100px;
            border: 3px solid palegoldenrod;
            padding: 10px;
        } */
    </style>
</head>

<body>
    <div id="app" >
        <!-- 2、全局組件的使用 -->
        <btn msg="父組件傳遞過來的值,123"></btn>
        <btn v-bind:msg="msg1"></btn>
        <btn :msg="msg2"></btn>   
    </div>
</body>

</html>

<script>
    //ctrl+/生成單行注釋

    Vue.component("btn",{
        template:"<div><button v-on:click='++count'>点击+1-当前值为：{{count}}</button><button>當前父組件傳遞過來的值為：{{msg}}</button></div>",
        data(){
            return {
                count:0 //定义count变量，初始值为0
            }
        },
        //接收父级传递的参数
        props:['msg']
    })

    new Vue({
        el: '#app',
        data:{
            msg1:"12132",
            msg2:"56"
            
        }
    })
</script>